package com.alameda.service.impl.statement;

import com.alameda.mapper.statement.AdSystemRecordMapper;
import com.alameda.pojo.statement.AdSystemRecordDO;
import com.alameda.service.statement.AdSystemRecordService;
import com.alameda.statement.enums.AdSystemRecordEnum;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 系统信息记录 业务逻辑层 具体实现
 *
 * @author Lv
 * @date 2024/07/13
 */
@Slf4j
@Service
public class AdSystemRecordServiceImpl extends ServiceImpl<AdSystemRecordMapper, AdSystemRecordDO> implements AdSystemRecordService {

    @Autowired
    private AdSystemRecordMapper adSystemRecordMapper;

    /**
     * 存储系统信息记录 (异步处理)
     *
     * @param adSystemRecordEnum 系统记录类型
     * @return
     */
    @Async
    @Override
    public Boolean saveRecord(AdSystemRecordEnum adSystemRecordEnum) {
        AdSystemRecordDO adSystemRecordDO = AdSystemRecordDO.builder()
                .recordKey(adSystemRecordEnum)
                .recordRemark(adSystemRecordEnum.getRemark())
                .build();

        return this.save(adSystemRecordDO);
    }
}
